package com.guan.ioc.controller;

import com.guan.ioc.model.UserInfo;
import com.guan.ioc.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@ResponseBody
@Controller
public class UserController {

    // 属性注入
    @Autowired
    private UserService userService;

//    @Autowired
//    @Qualifier("user2")
    @Resource(name = "user2")
    private UserInfo userInfo;

    public void sayHi() {
        userService.doService();
        System.out.println(userInfo);
        System.out.println("UserController sayHi...");
    }

    @RequestMapping("/hello")
    public String hello() {
        return "hello";
    }
}
